﻿using System;

namespace Microsoft.Practices.CompositeUI.Utility
{
    /// <summary>
    /// 	Generic arguments class to pass to event handlers that need to receive data.
    /// </summary>
    /// <typeparam name = "TData">The type of data to pass.</typeparam>
    public class DataEventArgs<TData> : EventArgs
    {
        #region Fields & Properties

        private readonly TData _data;

        /// <summary>
        /// 	Gets the information related to the event.
        /// </summary>
        public TData Data
        {
            get
            {
                return _data;
            }
        }

        #endregion

        #region Constructors

        /// <summary>
        /// 	Initializes the DataEventArgs class.
        /// </summary>
        /// <param name = "data">Information related to the event.</param>
        /// <exception cref = "ArgumentNullException">The data is null.</exception>
        public DataEventArgs(TData data)
        {
            Guard.ArgumentNotNull(data, "data");
            _data = data;
        }

        #endregion

        #region Overrides ToString

        /// <summary>
        /// 	Provides a string representation of the argument data.
        /// </summary>
        public override string ToString()
        {
            return _data.ToString();
        }

        #endregion
    }
}